package Dxc;

public class TestThread extends Thread {
    private String url;//图片网络地址
    private String name;//保存的文件名

    public TestThread(String url, String name) {
        this.url = url;
        this.name = name;
    }

    @Override
    public void run() {
        WebDownloader webDownloader = new WebDownloader();
        webDownloader.downloader(url, name);
        System.out.println("下载文件名为：" + name);
    }

    public static void main(String[] args) {
        TestThread testThread = new TestThread("https://cdn.aqdstatic.com:966/age/20070012_small.jpg", "2.jpg");

        testThread.start();

    }
}

//class WebDownloader {
//    public void downloader(String url, String name) {
//        try {
//            FileUtils.copyURLToFile(new URL(url), new File(name));
//        } catch (IOException e) {
//            e.printStackTrace();
//            System.out.println("IO异常，downloader方法出现问题");
//        }
//    }
//}